package com.gukewen;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.function.StreamBridge;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName MessageProducer
 * @Description
 * @Author gu
 * @Date 2025/11/4 15:05
 * @Version 1.0
 **/


@RestController
public class MessageProducer {

    @Autowired
    private StreamBridge streamBridge;

    // 访问 /send/{msg} 发送消息到 topic-a
    @GetMapping("/send/{msg}")
    public String send(@PathVariable String msg) {
        streamBridge.send("toA-out-0", msg);
        return "Producer 发送消息：" + msg;
    }
}